package com.wntms.wgj.dao;

import com.wntms.wgj.pojo.CarriageContracts;
import com.wntms.wgj.pojo.DriverSettle;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DriverSettleDao {
    /**
     * 查询司机结算表所有数据
     * @return
     */
    @Select("select * from driver_settle")
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "cid",column = "cid"),
            @Result(property = "moneyed",column = "moneyed"),
            @Result(property = "money",column = "money"),
            @Result(property = "carriageContracts",column = "cid",javaType = CarriageContracts.class,
                    one = @One(select = "com.wntms.wgj.dao.CarriageContractsDao.findById"))
    })
    public List<DriverSettle> findAll();

    /**
     * 司机结算
     * @param driverSettle
     * @return
     */
    @Update("update driver_settle set issettle = #{isSettle},moneyed = #{moneyed} where id = #{id}")
    public int updateSettle(DriverSettle driverSettle);

    /**
     * 删除司机结算记录
     * @param id
     * @return
     */
    @Delete("delete from driver_settle where id = #{id}")
    public int deleteSettle(Integer id);


    /**
     * 根据运输合同单号查询
     * @param cid
     * @return
     */
    @Select("select * from driver_settle where cid = #{cid}")
    @Results({
            @Result(id = true,property = "id",column = "id"),
            @Result(property = "cid",column = "cid"),
            @Result(property = "moneyed",column = "moneyed"),
            @Result(property = "money",column = "money"),
            @Result(property = "carriageContracts",column = "cid",javaType = CarriageContracts.class,
                    one = @One(select = "com.wntms.wgj.dao.CarriageContractsDao.findById"))
    })
    public DriverSettle findByCid(String cid);
}
